babl: add ability to register user data with BablModel
authorØyvind Kolås <pippin@gimp.org>
Sat, 17 Mar 2012 12:18:54 +0000 (12:18 +0000)
committerØyvind Kolås <pippin@gimp.org>
Sat, 17 Mar 2012 12:18:54 +0000 (12:18 +0000)
The user data is available in the callback functions, no ABI change only
processing functions interested in this data needs to define the arguments,..
keeping ABI compatibility.

babl/babl-conversion.c
babl/babl-conversion.h
babl/babl-fish-path.c
babl/babl-format.h
babl/babl-internal.h
babl/babl-model.c
babl/babl-model.h

index 0740d178d725b113df0f74be10d1362ac235cdb5..a7b312967b1fd43d69fb2e13b1dd38fe83b09e55 100644 (file)
@@ -288,7 +288,9 @@ babl_conversion_linear_process (BablConversion *conversion,
                                 void           *destination,
                                 long            n)
 {
-  return conversion->function.linear (source, destination, n);
+  return conversion->function.linear (source, destination, n,
+                              conversion->source->model.data,
+                              conversion->destination->model.data);
 }
 
 static long
@@ -301,7 +303,9 @@ babl_conversion_plane_process (BablConversion *conversion,
 {
   return conversion->function.plane (source, destination,
                                      src_pitch, dst_pitch,
-                                     n);
+                                     n,
+                                     conversion->source->model.data,
+                                     conversion->destination->model.data);
 }
 
 static long
@@ -327,7 +331,9 @@ babl_conversion_planar_process (BablConversion *conversion,
                                       destination->components,
                                       dst_data,
                                       destination->pitch,
-                                      n);
+                                      n,
+                                      conversion->source->model.data,
+                                      conversion->destination->model.data);
 }
 
 long
index 7b6cd4dbce908fa156560db3f1096a950852782d..336ec577efb52ea1df5534e0d3c77ef2925ea055 100644 (file)
@@ -32,7 +32,9 @@ typedef long (*BablFuncPlane)     (const char  *src,
                                    char        *dst,
                                    int          src_pitch,
                                    int          dst_pitch,
-                                   long         n);
+                                   long         n,
+                                   void        *src_model_data,
+                                   void        *dst_model_data);
 
 
 typedef struct
index 53cb6585971a8817c2a28d06b436177d43db82af..c7caa35aec222011df5148450a65e03468f2032d 100644 (file)
@@ -25,6 +25,7 @@
 #define BABL_HARD_MAX_PATH_LENGTH  8
 #define BABL_MAX_NAME_LEN          1024
 
+int   babl_in_fish_path = 0;
 
 typedef struct _FishPathInstrumentation
 {
@@ -292,8 +293,11 @@ babl_fish_path (const Babl *source,
      * a consistent state, this code path is not performance critical
      * since created fishes are cached.
      */
+    babl_in_fish_path++;
 
     get_conversion_path (&pc, (Babl *) source, 0, max_path_length ());
+
+    babl_in_fish_path--;
     babl_mutex_unlock (babl_format_mutex);
     babl_free (pc.current_path);
   }
index 68fc87d0e62466abb1df015be9de6b273e93103a..4dd4c4c06a88121354f4a53d0651e0028f330ecd 100644 (file)
@@ -28,6 +28,10 @@ typedef struct
   int              components;
   BablComponent  **component;
   BablType       **type;
+  void            *model_data;     /* replicated at same offset as in
+                                      BablModel, permitting assuming
+                                      that it is available for both
+                                    */
   void            *image_template; /* image template for use with
                                       linear (non-planer) images */
 
index 02723a5e2e38b50df43540bfbd2ea9fc87fe9138..bf857270a3cb5fb54cb49b835e50c89fe5708ed5 100644 (file)
@@ -220,6 +220,7 @@ babl_fatal (const char *format, ...)
 )
 
 extern int   babl_hmpf_on_name_lookups;
+extern int   babl_in_fish_path;
 extern BablMutex *babl_format_mutex;
 
 #define BABL_DEBUG_MEM 0
index df71be43b6cbfed409d1316aa60090ca26cabe77..f35e1a33b44e776cea0f5b4739d35c384151add4 100644 (file)
@@ -204,8 +204,8 @@ babl_model_new (void *first_argument,
   else
     {
       if (!is_model_duplicate (babl, components, component))
-        babl_fatal ("BablModel '%s' already registered "
-                    "with different components!", name);
+              babl_fatal ("BablModel '%s' already registered "
+                          "with different components!", name);
     }
 
   babl_free (name);
index 0a4786be530295812983fcd20ab1d65fec6459c3..4561fdba00401cdd6e1693b6ee33c1eaa6b1dcec 100644 (file)
@@ -29,6 +29,7 @@ typedef struct
   BablComponent  **component;
   BablType       **type; /*< must be doubles,
                              used here for convenience in code */
+  void            *data; /* used for palette */
 } BablModel;
 
 #endif